/**
 * Assistent.java.
 */
package rs.edu.fit.model;

import java.util.ArrayList;
import java.util.List;

import rs.edu.fit.model.interfaces.IWorkingWithExames;

public final class Assistent implements IWorkingWithExames {
	/** Assistent first name. */
	private String firstName;
	/** Assistent last name. */
	private String lastName;
	/** Assistent identification number. */
	private String identNumber;
	/** List of the exams. */
	private List<Exam> lExams;
	
//	private Logger log = Logger.getLogger("rs.edu.fit.model.Assistent");
	
	/** Default constructor. It is never used. */
	@SuppressWarnings("unused")
	private Assistent() {
		
	}

	/**
	 * Constructor with the parameters. It has all the parameters except list of
	 * exams, that is creating empty.
	 */
	public Assistent(final String firstName, final String lastName, 
			final String identNumber) {
		super();
		this.firstName = firstName;
		this.lastName = lastName;
		this.identNumber = identNumber;
		lExams = new ArrayList<Exam>();
		
//		BasicConfigurator.configure();
	}

	/** Constructor with all the elements. */
	public Assistent(String firstName, String lastName, String identNumber,
			List<Exam> lExams) {
		super();
		this.firstName = firstName;
		this.lastName = lastName;
		this.identNumber = identNumber;
		this.lExams = lExams;
		
//		BasicConfigurator.configure();
	}

	/*
	 * (non-Javadoc)
	 * @see rs.edu.fit.model.interfaces.IWorkingWithExames#addExam(rs.edu.fit.model.Exam)
	 */
	public final boolean addExam(final Exam exam) {
		if (!lExams.contains(exam)) {
//			log.info("Exam do not exist: adding " + exam);
			lExams.add(exam);
			return true;
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * @see rs.edu.fit.model.interfaces.IWorkingWithExames#addMultipleExams(java.util.List)
	 */
	public final void addMultipleExams( final List<Exam> lExamsToAdd) {
		for (Exam exam : lExamsToAdd ) {
			addExam(exam);
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see rs.edu.fit.model.interfaces.IWorkingWithExames#removeExam(rs.edu.fit.model.Exam)
	 */
	public final boolean removeExam( final Exam exam) {
		if (lExams.contains(exam)) {
			lExams.remove(exam);
			return true;
		}
		return false;
	}
	
	/*
	 * (non-Javadoc)
	 * @see rs.edu.fit.model.interfaces.IWorkingWithExames#removeMultipleExams(java.util.List)
	 */
	public final void removeMultipleExams( final List<Exam> lExamsToRemove) {
//		log.info("remove multiple exams");
		for (Exam exam : lExamsToRemove) {
			removeExam(exam);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(final Object o) {
		if (o instanceof Assistent) {
			Assistent asst = (Assistent) o;
			return this.identNumber.equals(asst.getIdentNumber());
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		int result = 37;
		result += identNumber.hashCode() * 27;
		
		return result;
	}

	
	/* Only getters, setters and toString from this point. */

	public final String getFirstName() {
		return firstName;
	}

	public final void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public final String getLastName() {
		return lastName;
	}

	public final void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public final String getIdentNumber() {
		return identNumber;
	}

	public final void setIdentNumber(String identNumber) {
		this.identNumber = identNumber;
	}

	public final List<Exam> getlExams() {
		return lExams;
	}

	public final void setlExams(List<Exam> lExams) {
		this.lExams = lExams;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Assistent [firstName=" + firstName + ", lastName=" + lastName
				+ ", identNumber=" + identNumber + ", lExams=" + lExams + "]";
	}
}
